#include <iostream>
#include <cstdio>

#define MAXN 210

using namespace std;

int a[MAXN], b[MAXN];
int db[5][5] = {{0,0,1,1,0}, {1,0,0,1,0}, {0,1,0,0,1}, {0,0,1,0,1}, {1,1,0,0,0}};

int main(){
    int n, na, nb;
    int ansa = 0, ansb = 0;
    cin >> n >> na >> nb;
    for (int i = 0; i < na; i++){
        scanf("%d", &a[i]);
    }
    for(int i = 0; i < nb; i++){
        scanf("%d", &b[i]);
    }
    for(int i = 0; i < n; i++){
        ansa += db[a[i % na]][b[i % nb]];  
        ansb += db[b[i % nb]][a[i % na]];
    }
    printf("%d %d", ansa, ansb);
    return 0;
}